/*


*/
$.fn.placeholder=function(){
	    $(this).each(function(index, element) {

			var placeholder = '';
			var self = $(element);
			if (!("placeholder" in document.createElement("input")) && (placeholder = $(element).attr("placeholder"))) {

					if(self.attr('type')!='password'){
						$(element).on("focus" ,function() {

							if ($(element).val() == placeholder) {
								$(element).val('');
							}
							$(element).css({color:''});
						});
						$(element).on("blur", function() {
							if ($(element).val() == "") {
								$(element).val(placeholder);
								$(element).css({color:'graytext'});
							}
						});

						//样式初始化
						if ($(element).val() == "") {
							$(element).val(placeholder);
							$(element).css({color:'graytext'});
						}

					}else{


						var html="<span id='pwdtag' style='position:absolute;left:20px;top:50%;margin-top:-7px;color:graytext;'>密码</span>"
						var fu = self[0].parentNode;
						fu.innerHTML+=html;

						$(document).on('focus','[type="password"]',function(){
							$(this).parent().find('span').text('');
						})
						$(document).on('blur','[type="password"]',function(){
							if($(this).val().length>0){
								$(this).parent().find('span').text('');
							}else{
								$(this).parent().find('span').text('密码');
							}

						})
						$(document).on('click','#pwdtag',function(){
							$(this).text('');
							$(this).prev().focus();
						})
					}
			}
		});
}